package com.cn.customer.housekeeping.housekeepingc.ui.helper;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.amap.api.services.core.PoiItem;
import com.cn.customer.housekeeping.housekeepingc.R;
import com.cn.customer.housekeeping.housekeepingc.bean.FriendRequestListResp;
import com.cn.customer.housekeeping.housekeepingc.bean.ServicekindListResp;
import com.cn.customer.housekeeping.housekeepingc.ui.base.BaseAdapterHelper;
import com.cn.customer.housekeeping.housekeepingc.ui.base.BaseImgView;
import com.cn.customer.housekeeping.housekeepingc.ui.base.QuickAdapter;
import com.cn.customer.housekeeping.housekeepingc.util.NavUtils;

import java.util.List;

public class ItemHelper {


    /***
     *
     */
    public QuickAdapter<FriendRequestListResp> setAdapter(Context context, List<FriendRequestListResp> datas) {
        QuickAdapter<FriendRequestListResp> adapter = new QuickAdapter<FriendRequestListResp>(context, R.layout.item_demo, datas) {
            @Override
            protected void convert(BaseAdapterHelper helper, FriendRequestListResp item) {
            }
        };
        return adapter;
    }

    /***
     *
     */
    public QuickAdapter<FriendRequestListResp> setAdapteMerchandise(Context context, List<FriendRequestListResp> datas) {
        QuickAdapter<FriendRequestListResp> adapter = new QuickAdapter<FriendRequestListResp>(context, R.layout.item_merchandise, datas) {
            @Override
            protected void convert(BaseAdapterHelper helper, FriendRequestListResp item) {

                RelativeLayout linred = (RelativeLayout) helper.getView(R.id.rl_xiangqing);
                linred.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        NavUtils.gotoMerchandiseDetailsActivity(context);
                    }
                });

            }
        };
        return adapter;
    }


    /***
     *
     */
    public QuickAdapter<FriendRequestListResp> setAdapterHomeList(Context context, List<FriendRequestListResp> datas) {
        QuickAdapter<FriendRequestListResp> adapter = new QuickAdapter<FriendRequestListResp>(context, R.layout.item_homelist, datas) {
            @Override
            protected void convert(BaseAdapterHelper helper, FriendRequestListResp item) {
            }
        };
        return adapter;
    }


    /***
     *
     */
    public QuickAdapter<ServicekindListResp> setAdapterOrderList(Context context, List<ServicekindListResp> datas) {
        QuickAdapter<ServicekindListResp> adapter = new QuickAdapter<ServicekindListResp>(context, R.layout.item_orderlist, datas) {
            @Override
            protected void convert(BaseAdapterHelper helper, ServicekindListResp item) {
//
                BaseImgView.ImageLoaderLoadimg((ImageView) helper.getView(R.id.img_merchandise),
                        item.getImgurl(), R.mipmap.icon_fang, R.mipmap.icon_fang, R.mipmap.icon_fang, 60, 60, 0);
//名称
                helper.setText(R.id.tv_name, item.getServicename());
                //内容
                helper.setText(R.id.tv_merchandise_price, item.getServicecontent());
                //价格
                helper.setText(R.id.tv_jiage, item.getPrice());
                //单位
                helper.setText(R.id.tv_danjia, "元/" + item.getUnit());
                //服务商家
                helper.setText(R.id.tv_danwei, item.getServiceshopname());
//已售
                helper.setText(R.id.tv_yishou, "已售 " + item.getSaledcount());
                //好评
                helper.setText(R.id.tv_haoping, "好评 " + item.getGoodcommentrate() + "%");

            }
        };
        return adapter;
    }


    /***
     *
     */
    public QuickAdapter<PoiItem> setAdapteMapChoice(Context context, List<PoiItem> datas) {
        QuickAdapter<PoiItem> adapter = new QuickAdapter<PoiItem>(context, R.layout.item_mapchoice, datas) {
            @Override
            protected void convert(BaseAdapterHelper helper, PoiItem item) {
                helper.setText(R.id.ship_name, item.getTitle());

                helper.setText(R.id.ship_content, item.getSnippet());
            }
        };
        return adapter;
    }


}
